﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Guedes_Library;

public partial class sustentabilidade : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["p"] == null)
        {
            Response.Redirect("sustentabilidade.aspx?p=3");
        }

        if (!Page.IsPostBack)
        {
            Repeater1.DataSource = getSust();
            Repeater1.DataBind();
        }
    }

    private List<sust> getSust()
    {
        List<sust> data;

        using (guedesEntities _db = new guedesEntities())
        {
            data = _db.sust
                   .OrderByDescending(n => n.ID)
                   .ToList();
        }
        return data;
    }

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Label t = (Label)e.Item.FindControl("lblTitulo");
        t.Text = (e.Item.DataItem as sust).Titulo;

        Literal l = (Literal)e.Item.FindControl("litContent");
        l.Text = (e.Item.DataItem as sust).Dica;
    }

}